import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: null,
    password: null,
  },
  mutations: {
    //修改state
    // 参数1: 固定,  参数2: 看情况
    updateUser(state, user) {
      state.user = user //参数2的用户信息 存放到state里
    },
    updateUser1(state, password) {
      state.password = password //参数2的用户信息 存放到state里
    },
  },
  actions: {},
  modules: {},
  plugins: [createPersistedState({
    storage: window.sessionStorage
  })] //保存在session中
})